"use strict";

/**
 * 文本内容入场动画:
 * 从下往上文本内容顺序入场
 */
!function () {
    var domMap = document.querySelectorAll(".anim-sort-in");
    if (domMap.length) {

        var animRenderCounter = 0; // 动画渲染数量
        var timeInterval = 50; // 动画时间间隔(ms)

        domMap.forEach(function (dom) {
            var textContent = dom.textContent;
            dom.innerHTML = ""

            textContent.trim().split("").map(function (item) {
                var span = document.createElement("span");
                if (!item.trim()) {
                    span.innerHTML = "&nbsp;";
                } else {
                    span.innerHTML = item;
                    span.style.setProperty("animation-delay", timeInterval * animRenderCounter + "ms");
                    animRenderCounter++;
                }

                dom.appendChild(span);
            });
        });
    }
}();